package com.fengyun.scala.annotation

import scala.annotation.switch

/**
 * @author Hanpeng
 * @date 2021/1/31 12:17
 * @description: 用于匹配的表达式
 *
 */
object Testswitch {
  def main(args: Array[String]): Unit = {
    val Constant = 'Q'
    def tokenMe(ch: Char) = (ch: @switch) match {
      case ' ' | '\t' | '\n'  => 1
      case 'A' | 'Z' | '$' | 'Q'    => 2
      case '5' | Constant     => 3  // a non-literal may prevent switch generation: this would not compile
      case _                  => 4
    }
  }
}
